<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>在线留言</title>
    <link rel="stylesheet" type="text/css" href="__CDN__/light/css/all.css"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div id="message">
    {include file="public/header" /}
    <!--联系我们 -->
    <div class="bg_gray common_small">
        <div class="common_pos">
            <div class="common_title">
                <ul>
                    <li>{$nav_name.title}</li>
                    <li>{$nav_name.eng_title}</li>
                </ul>
            </div>
        </div>
        <div class="center flex common_nav">
            <div class="common_left">
                <ul>
                    <li class="tab_active"><a href="">在线留言</a></li>
                    <li><a href="{:url('/index/contact/index',['nav_id'=>8])}">联系我们</a></li>
                </ul>
            </div>
            <div class="common_right">
                <div class="common_top"><img src="__CDN__/light/img/home_zofp.png"><a href="{:url('/index/index/index',['nav_id'=>1])}">网站首页</a> >> <a
                        href="">在线留言</a></div>
                <div class="common_bottom">
                    <form class="form" id="addForm">
                        <p>姓名<span>*</span></p>
                        <input type="text" name="name" id="name" value=""/>
                        <p>电话<span>*</span></p>
                        <input type="number" name="phone" id="phone" value=""/>
                        <p>邮箱<span>*</span></p>
                        <input type="text" name="email" id="email" value=""/>
                        <p>内容</p>
                        <textarea rows="" cols="" name="message"></textarea>
                        <button  id="sub" type="button">提交</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!--底部 -->
    <div class="footer">
        {include file="public/footer" /}
    </div>
</div>
<script>
    $(function() {
        $('#sub').on('click',function () {
            //获取表单的所有值,把值都放在一起
            var data=$('#addForm').serialize();
            $.ajax({
                //访问地址
                url:"{:url('message/add')}",
                type:"POST",
                //传值：本次提交传data的值
                data: data,
                //请求成功后的回调函数
                success:function(res){
                    if(res.code == 1){
                        alert(res.msg);
                        location.reload();
                    }else{
                        alert(res.msg);
                        return false;
                    }
                }
            });
        });
    })
</script>
</body>
</html>
